/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package MainClasses;

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;
/**
 *
 * @author andrewcutler
 */
public class AssignmentCheckBox extends JPanel implements MouseListener{

    private Assignment assign;
    //private MyEventHandler handler;
    
    public AssignmentCheckBox(Assignment s)
    {
        super();
        assign = s;
        
        
        this.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
        
        
        String classification = "";
            if(assign.isHomework()) {
                classification += "HW: "; 
                JCheckBox box = new JCheckBox();
                if(assign.isChecked())
                {
                    box.doClick();
                }
                box.addActionListener(new CheckboxListener());
                this.add(box);
            }
            if(assign.isClasswork())
                classification += "      CW: ";
            if(assign.isTest())
                classification += "      Test: ";
        
        JLabel l = new JLabel(classification + s.getTitle());
        this.add(l);
        l.addMouseListener(this);
    }

    private void classPopup()
    {
        System.out.println("ClassPopUp");
    }
    public void mouseClicked(MouseEvent arg0) {
        try
        {
            //MainClasses.EventListeners.CheckboxListener.assignmentPopup(assign);
        }
        catch(Exception e)
        {
            System.out.println(e);
        }
    }

    public void mousePressed(MouseEvent arg0) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseReleased(MouseEvent arg0) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseEntered(MouseEvent arg0) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

    public void mouseExited(MouseEvent arg0) {
        //throw new UnsupportedOperationException("Not supported yet.");
    }
    
    
    private class CheckboxListener implements ActionListener
    {
        
        public void actionPerformed(ActionEvent arg0) {
            assign.check();
        }
    }
    
}
